<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Stores a file in the database</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongogridfs.get.html">MongoGridFS::get</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongogridfs.remove.html">MongoGridFS::remove</a></div>
 <div class="up"><a href="class.mongogridfs.html">MongoGridFS</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongogridfs.put" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoGridFS::put</h1>
  <p class="verinfo">(PECL mongo &gt;=1.0.8)</p><p class="refpurpose"><span class="refname">MongoGridFS::put</span> &mdash; <span class="dc-title">Stores a file in the database</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongogridfs.put-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>MongoGridFS::put</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$metadata</code><span class="initializer"> = array()</span></span>
  ] )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongogridfs.put-parameters">
 <h3 class="title">参数</h3>
 <p class="para">
  <dl>

   
    <dt>

     <em><code class="parameter">filename</code></em>
    </dt>

    <dd>

     <p class="para">
      Name of the file to store.
     </p>
    </dd>

   
   
    <dt>

     <em><code class="parameter">metadata</code></em>
    </dt>

    <dd>

     <p class="para">
      Other metadata fields to include in the file document.
     </p>
     <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">These fields may also overwrite those that would be created automatically by the driver, as described in the MongoDB core documentation for the <a href="http://docs.mongodb.org/manual/core/gridfs/#the-files-collection" class="link external">&raquo;&nbsp;files collection</a>. Some practical use cases for this behavior would be to specify a custom <em>chunkSize</em> or <em>_id</em> for the file.</p></p></blockquote>
    </dd>

   
  </dl>

 </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongogridfs.put-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">Returns the <em>_id</em> of the saved file document. This will be a generated <a href="class.mongoid.html" class="classname">MongoId</a> unless an <em>_id</em> was explicitly specified in the <em><code class="parameter">extra</code></em> parameter.</p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongogridfs.put-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="mongogridfs.storebytes.html" class="function" rel="rdfs-seeAlso">MongoGridFS::storeBytes()</a> - Stores a string of bytes in the database</span></li>
   <li class="member"><span class="function"><a href="mongogridfs.storefile.html" class="function" rel="rdfs-seeAlso">MongoGridFS::storeFile()</a> - Stores a file in the database</span></li>
   <li class="member"><span class="function"><a href="mongogridfs.storeupload.html" class="function" rel="rdfs-seeAlso">MongoGridFS::storeUpload()</a> - Stores an uploaded file in the database</span></li>
   <li class="member">MongoDB core docs on <a href="http://docs.mongodb.org/manual/core/gridfs/" class="link external">&raquo;&nbsp;GridFS</a></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongogridfs.get.html">MongoGridFS::get</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongogridfs.remove.html">MongoGridFS::remove</a></div>
 <div class="up"><a href="class.mongogridfs.html">MongoGridFS</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
